from PIL import Image, ImageFont, ImageDraw

def CreatePicture(monthname, weeknumber):
    #Переменные
    image_path = "./photos/9.png"
    image      = Image.open(image_path)
    draw       = ImageDraw.Draw(image)
    fill       = "#FFFFFF"

    #Месяц
    draw.text(
        (image.size[0]//2, 550),
        monthname,
        anchor = "mm",
        fill   = fill,
        font   = ImageFont.truetype('./fonts/Tenor_Sans/TenorSans-Regular.ttf', 112)
    )

    #Недели и числа
    ims = image.size[0]//2

    #Недели
    weekname = ["ПН", "ВТ", "СР", "ЧТ", "ПТ", "СБ", "ВС"]
    weekname_position = [
        (ims-375,700),  
        (ims-250,700),  
        (ims-125,700),  
        (ims,700),  
        (ims+125,700),  
        (ims+250,700),  
        (ims+375,700)
    ]
    for week in weekname:
        draw.text(
            weekname_position[weekname.index(week)],
            week,
            anchor = "mm",
            fill   = fill,
            font   = ImageFont.truetype('./fonts/Oswald/static/Oswald-Medium.ttf', 36)
        )

    #Числа
    dateweek = weeknumber
    dateweek_position = [
        (ims-375,800),  (ims-250,800),  (ims-125,800),  (ims,800),  (ims+125,800),  (ims+250,800),  (ims+375,800),
        (ims-375,900),  (ims-250,900),  (ims-125,900),  (ims,900),  (ims+125,900),  (ims+250,900),  (ims+375,900),
        (ims-375,1000), (ims-250,1000), (ims-125,1000), (ims,1000), (ims+125,1000), (ims+250,1000), (ims+375,1000),
        (ims-375,1100), (ims-250,1100), (ims-125,1100), (ims,1100), (ims+125,1100), (ims+250,1100), (ims+375,1100),
        (ims-375,1200), (ims-250,1200), (ims-125,1200), (ims,1200), (ims+125,1200), (ims+250,1200), (ims+375,1200),
        (ims-375,1300), (ims-250,1300), (ims-125,1300), (ims,1300), (ims+125,1300), (ims+250,1300), (ims+375,1300),
    ]

    for dates in dateweek:
        draw.text(
            dateweek_position[dateweek.index(dates)],
            dates,
            anchor = "mm",
            fill   = fill,
            font   = ImageFont.truetype('./fonts/Oswald/static/Oswald-Medium.ttf', 36)
        )

    #Футер
    footer     = ["ЗАБРОНИРОВАТЬ", "МОМЕНТ"]
    footer_position = [(image.size[0]//2, image.size[1]-275), (image.size[0]//2, image.size[1]-200)]

    for text in footer:
        draw.text(
            footer_position[footer.index(text)],
            text,
            anchor = "mm",
            fill   = fill,
            font   = ImageFont.truetype('./fonts/Kosugi_Maru/KosugiMaru-Regular.ttf', 48)
        )

    #Показать изображение
    # image.show()
    image.save('./photos/month.png')
